package com.conan.spring5.service;

import com.conan.spring5.dao.UserDAO;
import com.conan.spring5.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @version 加油！！！
 * @Description
 * @Author 谷藤新一GYC
 * @Date 2022/10/22 - 15:58
 */
@Service(value = "userService")
@Transactional(timeout = 10,propagation = Propagation.REQUIRED,isolation = Isolation.REPEATABLE_READ)
public class UserServiceImpl implements UserService{

    @Autowired
    private UserDAO userDAO;


    @Override
    public void updateMoney(Integer money, User user1,User user2) {
        userDAO.reduceMoney(money,user1);

//        int i =10/0;
        userDAO.addMoney(money,user2);

    }


    @Override
    public User getUserById(Integer id) {
        return userDAO.getUserById(id);
    }
}
   